<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<input type='text' id='txt1' value="" /> 
   <select id='select'>
    <option value='0'>+</option>
    <option value="1">-</option>
    <option value="2">*</option>
    <option value="3">/</option>
   </select>
   <input type='text' id='txt2'  /> 
   <input type='button' value=' = ' onclick="count()" /> <!--通过 = 按钮来调用创建的函数，得到结果--> 
   <input type='text' id='fruit' />  
</body>
<script type="text/javascript">
   function count(){
    var a= parseInt(document.getElementById("txt1").value);//获取第一个输入框的值
    var b = parseInt(document.getElementById("txt2").value);//获取第二个输入框的值
    var c=parseInt(document.getElementById("select").value);
  switch(c){
     case 0: document.getElementById("fruit").value=add(a,b);break;
     case 1:document.getElementById("fruit").value=sum(a,b);break;
     case 2:document.getElementById("fruit").value=app(a,b);break;
     case 3:document.getElementById("fruit").value=divs(a,b);break;
     }//获取通过下拉框来选择的值来改变加减乘除的运算法则
  //设置结果输入框的值
   }
   function add(a,b){
     suma=a+b;
     return suma;
     }
     function sum(a,b){
     sumb=a-b;
     return sumb;
     }
     function app(a,b){
     sumc=a*b;
     return sumc;
     }
     function divs(a,b){
     sumd=a/b;
     return sumd;
     }
  </script> 
</html>